package br.com.news.web;

public enum ManagedBeanAccess {

	DADOSPESSOAIS{

		@Override
		public String route() {
			return DadosPessoaisMB.ROUTE;
		}

		@Override
		public Class<? extends BaseMB> managedBean() {
			return DadosPessoaisMB.class;
		}
		
	},
	
	ENQUETE{

		@Override
		public String route() {
			return EnqueteMB.ROUTE;
		}

		@Override
		public Class<? extends BaseMB> managedBean() {
			return EnqueteMB.class;
		}
		
	},
	
	USUARIO{

		@Override
		public String route() {
			return UsuarioMB.ROUTE;
		}

		@Override
		public Class<? extends BaseMB> managedBean() {
			return UsuarioMB.class;
		}
		
	},
	
	CATEGORIA{

		@Override
		public String route() {
			return CategoriaMB.ROUTE;
		}

		@Override
		public Class<? extends BaseMB> managedBean() {
			return CategoriaMB.class;
		}
		
	},
	
	CADASTRO{

		@Override
		public String route() {
			return CadastroMB.ROUTE;
		}

		@Override
		public Class<? extends BaseMB> managedBean() {
			return CadastroMB.class;
		}
		
	},
	
	NOTICIA{

		@Override
		public String route() {
			return NoticiaAdminMB.ROUTE;
		}

		@Override
		public Class<? extends BaseMB> managedBean() {
			return NoticiaAdminMB.class;
		}
		
	};
	
	public abstract String route();
	
	public abstract Class<? extends BaseMB> managedBean();
	
	public static ManagedBeanAccess fromRoute(final String route) {
		ManagedBeanAccess[] values = ManagedBeanAccess.values();
		
		for(ManagedBeanAccess r : values) {
			if(r.route().equals(route)) {
				return r;
			}
		}
		
		return null;
	}
	
}
